package com.ninetaildemonfox.zdl.socialproject.mvp.presenter;

import android.support.v7.app.AppCompatActivity;
import android.text.TextUtils;

import com.google.gson.JsonObject;
import com.ninetaildemonfox.zdl.socialproject.config.Constants;
import com.ninetaildemonfox.zdl.socialproject.http.https.Model;
import com.ninetaildemonfox.zdl.socialproject.utils.ToastUtil;

import java.util.Map;

import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 创建人： Nine tails fox
 * 创建时间： 2019/8/6
 * 功能描述：
 * 联系方式：1037438704@qq.com
 *
 * @author NineTailDemonFox
 */

public class FeedBackPresenter {
    public void getAddFeedBack(String token, String content, String phone, final AppCompatActivity activity) {
        if (TextUtils.isEmpty(phone)){
            ToastUtil.show("请输入您的联系方式");
            return;
        }

        Model.getInstance().getUserApi().getAddFeedBack(token, content, phone).enqueue(new Callback<JsonObject>() {
            @Override
            public void onResponse(Call<JsonObject> call, Response<JsonObject> response) {
                Map<String, String> map = Constants.codeGet(activity, response);
                if (map == null) {
                    return;
                }
                ToastUtil.show(map.get("message"));
                activity.finish();
            }

            @Override
            public void onFailure(Call<JsonObject> call, Throwable t) {

            }
        });
    }
}
